package io.spring.guides.gs_producing_web_service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;

/**
 * @Author:wangshuliang
 * @Description:
 * @Date:Created in 15:09 2019/5/21
 * @Modified by:
 */
@Endpoint
public class CountryEndpoint {
    private static final String NAMESPACE_URI="http://spring.io/guides/gs-producing-web-service";

    private CountryRepository countryRepository;
    @Autowired
    public CountryEndpoint(CountryRepository countryRepository) {
        this.countryRepository = countryRepository;
    }
    @PayloadRoot(namespace = NAMESPACE_URI,localPart = "getCountryRequest")
    @ResponsePayload
    public GetCountryResponse getCountry(@RequestPayload GetCountryRequest request){
        GetCountryResponse getCountryResponse = new GetCountryResponse();
        getCountryResponse.setCountry(countryRepository.findCountry(request.getName()));
        return getCountryResponse;
    }
}
